using FreeSql.DataAnnotations;

namespace SumerCoreDevOps.Domain.Entities;

/// <summary>
/// Docker 镜像仓库配置
/// </summary>
[Table(Name = "docker_registries")]
public class DockerRegistry
{
    /// <summary>
    /// 仓库 ID
    /// </summary>
    [Column(IsPrimary = true, IsIdentity = true)]
    public long Id { get; set; }

    /// <summary>
    /// 仓库名称
    /// </summary>
    [Column(StringLength = 200, IsNullable = false)]
    public string Name { get; set; } = null!;

    /// <summary>
    /// 仓库类型：DockerHub、Harbor、ECR、ACR、自定义
    /// </summary>
    [Column(StringLength = 50, IsNullable = false)]
    public string RegistryType { get; set; } = null!;

    /// <summary>
    /// 仓库地址
    /// </summary>
    [Column(StringLength = 500, IsNullable = false)]
    public string RegistryUrl { get; set; } = null!;

    /// <summary>
    /// 用户名（已加密）
    /// </summary>
    [Column(StringLength = 500)]
    public string? Username { get; set; }

    /// <summary>
    /// 密码（AES-256 加密）
    /// </summary>
    [Column(StringLength = 1000)]
    public string? EncryptedPassword { get; set; }

    /// <summary>
    /// API Token（用于某些仓库，如 ECR）
    /// </summary>
    [Column(StringLength = 2000)]
    public string? ApiToken { get; set; }

    /// <summary>
    /// 是否使用 HTTPS
    /// </summary>
    [Column(IsNullable = false)]
    public bool UseHttps { get; set; } = true;

    /// <summary>
    /// 是否跳过 SSL 验证（不建议在生产环境使用）
    /// </summary>
    [Column(IsNullable = false)]
    public bool SkipSslVerify { get; set; } = false;

    /// <summary>
    /// 最大重试次数
    /// </summary>
    [Column(IsNullable = false)]
    public int MaxRetries { get; set; } = 3;

    /// <summary>
    /// 重试间隔（秒）
    /// </summary>
    [Column(IsNullable = false)]
    public int RetryIntervalSeconds { get; set; } = 5;

    /// <summary>
    /// 是否启用
    /// </summary>
    [Column(IsNullable = false)]
    public bool IsEnabled { get; set; } = true;

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(IsNullable = false)]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 创建者
    /// </summary>
    [Column(StringLength = 100)]
    public string? CreatedBy { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdatedAt { get; set; }
}
